Fix a couple of issues with the new gpx writer having to do with chains and garmin...
authortsteven4 <tsteven4@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 24 Feb 2013 18:13:28 +0000 (18:13 +0000)
committertsteven4 <tsteven4@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 24 Feb 2013 18:13:28 +0000 (18:13 +0000)
git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4324 f51c46e8-681c-474f-0cfe-069cfd0219fb

gpsbabel/garmin_fs.cc
gpsbabel/gpx.cc

index f75afe53d1fc0f122fc121fb4b5afa012113be15..fff3631c1e31f18ed35705f3d9f87648faa26e3e 100644 (file)
@@ -234,13 +234,25 @@ garmin_fs_xml_fprint(gbfile* ofd, const waypoint* waypt,
       "http://www.garmin.com/xmlschemas/GpxExtensions/v3/GpxExtensionsv3.xsd");
 #endif
     if WAYPT_HAS(waypt, proximity) {
+#if OLDGPX
       gbfprintf(ofd, "%*s<gpxx:Proximity>%.6f</gpxx:Proximity>\n", space * 2, "", waypt->proximity);
+#else
+      writer.writeTextElement("gpxx:Proximity", QString::number(waypt->proximity, 'f', 6));
+#endif
     }
     if WAYPT_HAS(waypt, temperature) {
+#if OLDGPX
       gbfprintf(ofd, "%*s<gpxx:Temperature>%.6f</gpxx:Temperature>\n", space * 2, "", waypt->temperature);
+#else
+      writer.writeTextElement("gpxx:Temperature",  QString::number(waypt->temperature, 'f', 6));
+#endif
     }
     if WAYPT_HAS(waypt, depth) {
+#if OLDGPX
       gbfprintf(ofd, "%*s<gpxx:Depth>%.6f</gpxx:Depth>\n", space * 2, "", waypt->depth);
+#else
+      writer.writeTextElement("gpxx:Depth", QString::number(waypt->depth, 'f', 6));
+#endif
     }
     if (gmsd->flags.display) {
       const char* cx;
index 880a1ffe8990936cab66b5d559010d6ed6c3c80b..bb408f4ac864676270fa6f1241a0fd8d1f0944c2 100644 (file)
@@ -1582,6 +1582,7 @@ fprint_xml_chain(xml_tag* tag, const waypoint* wpt)
 #endif
     }
     if (tag->parentcdata) {
+#if OLDGPX
       // retain whitespacing, but nuke leading NL as the above will add a trailing.
 
       char* otmp_ent, *tmp_ent = NULL;
@@ -1592,6 +1593,13 @@ fprint_xml_chain(xml_tag* tag, const waypoint* wpt)
         tmp_ent = otmp_ent;
       gbfprintf(ofd, "%s", tmp_ent);
       xfree(otmp_ent);
+#else
+      // FIXME: The length check is necessary to get line endings correct in our test suite.
+      // Writing the zero length string eats a newline, at least with Qt 4.6.2.
+      if (tag->parentcdatalen > 0) {
+        writer.writeCharacters(tag->parentcdata);
+      }
+#endif
     }
     tag = tag->sibling;
   }
@@ -1811,18 +1819,18 @@ gpx_write_common_extensions(const waypoint* waypointp, const char* indent)
     writer.writeStartElement("extensions");
     if (waypointp->depth != 0) {
       if (opt_humminbirdext) {
-        writer.writeTextElement("h:depth", QString::number(waypointp->depth * 100.0));
+        writer.writeTextElement("h:depth", QString::number(waypointp->depth * 100.0, 'f', 6));
       }
       if (opt_garminext) {
-        writer.writeTextElement("gpxx:Depth", QString::number(waypointp->depth));
+        writer.writeTextElement("gpxx:Depth", QString::number(waypointp->depth, 'f', 6));
       }
     }
     if (waypointp->temperature != 0) {
       if (opt_humminbirdext) {
-        writer.writeTextElement("h:temperature", QString::number(waypointp->temperature));
+        writer.writeTextElement("h:temperature", QString::number(waypointp->temperature, 'f', 6));
       }
       if (opt_garminext) {
-        writer.writeTextElement("gpxx:Temperature", QString::number(waypointp->temperature));
+        writer.writeTextElement("gpxx:Temperature", QString::number(waypointp->temperature, 'f', 6));
       }
     }
     if (opt_garminext && (waypointp->heartrate != 0 || waypointp->cadence != 0)) {